package com.jia.lidao.ui.personal;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.TextView;

import com.jia.lidao.R;
import com.jia.lidao.ui.BaseActivity;
import com.jia.lidao.ui.personal.adapter.MyPagerAdapter;
import com.jia.lidao.widget.CustomViewPager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jia on 17/12/16.
 */

public class OrderListActivity extends BaseActivity implements View.OnClickListener{


    private TextView myTxt,otherTxt;

    private MyPagerAdapter adapter;

    private List<Fragment> fragmentList;

    private CustomViewPager viewPager;

    public static final String CURENT="curent";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_orderlist);
        initView();
        initData();
    }



    private void initView() {
        myTxt=(TextView)findViewById(R.id.orderlist_my_txt);
        otherTxt=(TextView)findViewById(R.id.orderlist_other_txt);
        viewPager=(CustomViewPager)findViewById(R.id.orderlist_viewpager);
        fragmentList=new ArrayList<>();
        for (int i=0;i<2;i++) {
            fragmentList.add(OrderListFragment.newInstance(i));
        }
        adapter=new MyPagerAdapter(getSupportFragmentManager(),fragmentList);
        viewPager.setAdapter(adapter);
        myTxt.setOnClickListener(this);
        otherTxt.setOnClickListener(this);
        findViewById(R.id.orderlist_back_rl).setOnClickListener(this);
    }

    private void initData() {



    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.orderlist_back_rl:
                finish();
                break;
            case R.id.orderlist_my_txt:
                myTxt.setBackgroundResource(R.drawable.shape_left_choosed);
                myTxt.setTextColor(getResources().getColor(R.color.common_text_white));
                otherTxt.setBackgroundResource(R.drawable.shape_right_choose);
                otherTxt.setTextColor(getResources().getColor(R.color.common_bg_green));
                viewPager.setCurrentItem(0);
                break;
            case R.id.orderlist_other_txt:
                myTxt.setBackgroundResource(R.drawable.shape_left_choose);
                myTxt.setTextColor(getResources().getColor(R.color.common_bg_green));
                otherTxt.setBackgroundResource(R.drawable.shape_right_choosed);
                otherTxt.setTextColor(getResources().getColor(R.color.common_text_white));
                viewPager.setCurrentItem(1);
                break;
        }
    }
}
